package pl.easyshop.core.common.selectable;

import java.io.Serializable;

/**
 * Simple implementation of {@link SelectableItem} interface.
 * 
 * @author pwitkowski
 */
public class SimpleSelectableItem<L, V> implements SelectableItem<L, V>, Serializable {

	/** Unique serialization identifier. */
	private static final long serialVersionUID = 6174685311020614755L;

	/** Identifier. */
	private V id;
	
	/** Label. */
	private L label;
	
	/** Boudle message code. */
	private String messageCode;
	
	/** Value <code>true</code> means label is boudle message code. */
	private boolean boudleMessage;
	
	/** Default constructor*/
	public SimpleSelectableItem() {}
	
	/**
	 * Constructor.
	 * 
	 * @param label label.
	 * @param value value.
	 */
	public SimpleSelectableItem(L label, V value) {
		this.id = value;
		this.label = label;
		this.boudleMessage = false;
	}
	
	/**
	 * Constructor.
	 * 
	 * @param label label.
	 * @param value value.
	 * @param boudleMessage <code>true</code> means label is message boudle code.
	 */
	public SimpleSelectableItem(L label, V value, String messageCode) {
		this.id = value;
		this.label = label;
		this.messageCode = messageCode;
		this.boudleMessage = true;
	}


	/* (non-Javadoc)
	 * @see pl.pwitkowski.tas.core.service.SelectableItem#getItemLabel()
	 */
	public L getItemLabel() {
		return label;
	}

	/* (non-Javadoc)
	 * @see pl.pwitkowski.tas.core.service.SelectableItem#getItemValue()
	 */
	public V  getItemValue() {
		return id;
	}

	/* (non-Javadoc)
	 * @see pl.pwitkowski.tas.core.common.selectable.SelectableItem#isBoudleMessage()
	 */
	public boolean isBoudleMessage() {
		return boudleMessage;
	}

	/**
	 * Get messageCode property value.
	 * @return the messageCode
	 */
	public String getMessageCode() {
		return messageCode;
	}

	/**
	 * Set messageCode property value.
	 * @param messageCode the messageCode to set
	 */
	public void setMessageCode(String messageCode) {
		this.messageCode = messageCode;
	}

}
